<%--
  Created by IntelliJ IDEA.
  User: gaosubo
  Date: 2020/9/9
  Time: 13:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>评分标准</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>

    <script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.all.js?20200715.1" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/UEcontroller.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/formdesign/bootstrap/js/bootstrap.js?20200826" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="cont" style="margin: 10px">
    <form class="layui-form" action="" id="ajaxforms" lay-filter="ajaxforms">
        <h3 class="information">【基本信息】</h3>

        <div class="layui-form-item" style="margin-top: 15px">
            <label class="layui-form-label">申报计划</label>
            <div class="layui-input-block" style="width: 50%;">
                <input type="text" name="planName"  autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">项目来源</label>
            <div class="layui-input-block" style="width: 50%;">
                <select name="source" lay-verify="required" class="source" lay-search="">
                    <option value="">请选择</option>
                    <option value="01" title="教育部">教育部</option>
                    <option value="02" title="区级">区级</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">项目级别</label>
            <div class="layui-input-block" style="width: 50%;">
                <select name="lev" lay-verify="required" lay-search="">
                    <option value="">请选择</option>
                    <option value="01">国际级</option>
                    <option value="02">国家级</option>
                    <option value="03">部省级</option>
                    <option value="04">省专项</option>
                    <option value="05">厅市级</option>
                    <option value="06">其他</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">项目分类</label>
            <div class="layui-input-block" style="width: 50%;">
                <select name="category" lay-verify="required" lay-search="">
                    <option value="">请选择</option>
                    <option value="01">工类</option>
                    <option value="02">社科类</option>
                    <option value="03">其它</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">计划描述</label>
            <div class="layui-input-block" style="width: 50%;">
                <textarea placeholder="请输入内容" class="layui-textarea des"  name="des"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">开始日期</label>
            <div class="layui-input-block" style="width: 50%;">
                <input type="text" name="beginDate" id="date" lay-verify="date" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">结束日期</label>
            <div class="layui-input-block" style="width: 50%;">
                <input type="text" name="endDate" id="date1" lay-verify="date" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">申报状态</label>
            <div class="layui-input-block" style="width: 50%;">
                <input type="text" name="state"  autocomplete="off" disabled class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">计划状态</label>
            <div class="layui-input-block" style="width: 50%;">
                <input type="radio" name="reviewStatus" value="1" title="未开始" checked="">
                <input type="radio" name="reviewStatus" value="2" title="评审中" >
                <input type="radio" name="reviewStatus" value="3" title="评审结束">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">评价分数</label>
            <div class="layui-input-block" style="width: 50%;">
                <input type="text" name="reviewFraction"  autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">评分规则</label>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 43px;  margin-right: 43px;">
                <div id="container" style="width: 99.9%;min-height: 300px;" name="content" type="text/plain"></div>
            </div>
        </div>
    </form>
</div>
<script>
    // 获取地址栏参数值
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var planId = getQueryString('planId');
    var table,form,laydate,upload,layedit;
    var ue;

    $(function(){
        ue = UE.getEditor('container',{elementPathEnabled : false});

        layui.use(['table', 'form', 'laydate','upload','layedit'], function () {
            table = layui.table,
                form = layui.form,
                laydate = layui.laydate,
                upload = layui.upload,
                layedit = layui.layedit;

            //渲染日期
            laydate.render({
                elem: '#date'
                , trigger: 'click'//呼出事件改成click
            });
            laydate.render({
                elem: '#date1'
                , trigger: 'click'//呼出事件改成click
            });

            $.ajax({
                url:'/rpmPlan/selectByKey',
                dataType: 'json',
                type: 'get',
                data:{
                    planId:planId
                },
                success:function (res) {
                    var obj = res.object;
                    if (obj['state'] == '1'){
                        obj['state'] = '未开始';
                    }else if(obj['state'] == '2'){
                        obj['state'] = '评审中';
                    }else{
                        obj['state'] = '评审结束';
                    }
                    form.val("ajaxforms",obj);

                    //编辑器回显
                    ue.ready(function(){
                        ue.setContent(obj.scoreRule);
                    });

                }
            })

        });
    });

    function submitEdit() {
        var obj = {}
        obj.planId = planId
        obj.planName = $('input[name="planName"]').val()
        obj.source = $('select[name="source"]').val()
        obj.lev = $('select[name="lev"]').val()
        obj.category = $('select[name="category"]').val()
        obj.des = $('.des').val()
        obj.beginDate = $('input[name="beginDate"]').val()
        obj.endDate = $('input[name="endDate"]').val()
        obj.display = $('input[name="display"]:checked').val()
        obj.reviewStatus = $('input[name="reviewStatus"]:checked').val()
        obj.reviewFraction = $('input[name="reviewFraction"]').val()
        obj.scoreRule =  ue.getContent();
        $.ajax({
            url: '/rpmPlan/updateByKey',
            dataType: 'json',
            type: 'get',
            data: obj,
            success: function (res) {
                if (res.flag) {
                    parent.closes();
                }
            }
        })
    }

</script>
</body>
</html>
